package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.data.entity.BusinessModelField;
import com.nbsaas.boot.project.api.domain.request.BusinessModelFieldRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.project.data.entity.BusinessModel;
            import com.nbsaas.boot.common.data.entity.DataType;

/**
* 请求对象转换成实体对象
*/

public class BusinessModelFieldEntityConvert  implements Converter<BusinessModelField, BusinessModelFieldRequest> {

    @Override
    public BusinessModelField convert(BusinessModelFieldRequest source) {
        BusinessModelField result = new BusinessModelField();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getBusinessModel()!=null){
                    BusinessModel businessModel =new BusinessModel();
                    businessModel.setId(source.getBusinessModel());
                    result.setBusinessModel(businessModel);
                    }
                    if(source.getDataType()!=null){
                    DataType dataType =new DataType();
                    dataType.setId(source.getDataType());
                    result.setDataType(dataType);
                    }
        return result;
    }
}

